package com.qk.management.controller;


import com.qk.common.enums.BizEnum;
import com.qk.common.util.AliYunOSSOperators;
import com.qk.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:gzc
 * @Date: 2025/08/29 20:35
 * @Description:
 */
@RestController
public class UploadController {

    @Autowired
    private AliYunOSSOperators aliYunOSSOperators;
    @PostMapping("/upload")
    public Result upload(@RequestParam("image") MultipartFile file) {
        try {
            String url = aliYunOSSOperators.upload(file.getBytes(), file.getOriginalFilename());
            return Result.success(url);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(BizEnum.UPLOAD_ERROR.getMsg());
        }
    }
}
